package com.bnz.service.impl;

import com.bnz.dao.UserDao;
import com.bnz.pojo.User;
import com.bnz.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public void trans(int uidOut, int uidIn, double money) {

        //转出
        userDao.updateUser(uidOut, -money);
        //int i=10/0;
        //转入
        userDao.updateUser(uidIn, money);

    }

    //添加
    @Override
    public void add(User user) {

        userDao.addUser(user);
    }

    @Override
    public User findById(int id) {
       return userDao.findById(id);
    }

    @Override
    public void update(User user) {
        userDao.update(user);
    }

    @Override
    public void delete(int id) {
        userDao.delete(3);
    }
}
